from java.util import Locale
from net.omnivention.wulumuqi import URLResourceBundle, WuluUtil

lang = request.getParameter("lang").upper()
locale = eval("Locale."+lang) #for example: Locale.CHINESE, Locale.ENGLISH

resourceBundle = document.getElementById("resourceBundle").getAttributeValue("resourceBundle")

url = resourceBundle
if resourceBundle.find("http") == -1:
	contextURL = WuluUtil.getContextURL(request.getRequestURL().toString())
	url = contextURL+resourceBundle

resource = URLResourceBundle(url+"_"+locale.toString()+".properties")
	
nodes = document.selectNodes("//*[starts-with(text(),'$')]")
for n in nodes:
	key = n.getText().strip()
	val = resource.getString(key)
	n.setText(val)